$('#all').click(function(){
    $('#more').removeClass('se');
    $(this).addClass('se');
    $('.userbox').remove();
    let html = `<input type="hidden" name="type" value="0" id="type">`;
    $('.middle').html(html);
});
$('#more').click(function(){
    $('#all').removeClass('se');
    $(this).addClass('se');
    let box = `<div class="userbox put"> </div><div class="userbox sel"></div>`
    $('.middle').html(box);
    let data = AjaxForm('admin/userlist?limit=50');
    let html = ``;
    for (let i=0;i<data.list.length;i++){
        html += `<span ids="${data.list[i].uid}" class="user add">${data.list[i].nickname}</span>`;
    }
    $('.sel').html(html);
    $('.add').click(function(){
        let nickname =  $(this).text();
        let uid = $(this).attr('ids');
        let put = `<span ids="${uid}" id="u${uid}" class="user del">${nickname}</span>`;
        if($('#u'+uid).length <= 0){
            $('.put').append(put);
            $('.del').click(function(){
                $(this).remove();
            });
        }
    });
});


$('#push').click(function(){
    let model = $(".modelselet").val();
    let uid = ``;
    if(model == 0)return lay('请选择发布区域');
    if($('.se').text() == '所有人'){
        uid = $('#type').val();
    }else{
        let box = $('.del');
        for (let i=0;i<box.length;i++){
            uid += $(box[i]).attr('ids')+',';
        }
        if(uid == ``)return lay('请选择用户');
    }
    let content = $('#content').val();
    if(content == ``)return lay('请输入内容');
    let title = $('#title').val();
    if(title == ``)return lay('请输入标题');
    let putdata = {model:model,uid:uid,content:content,title:title};
    layFirm('发送','admin/MsgSend',putdata);
});